/**
 **************************************************************************************************************************
 * Class For Ref Counting objects
 **************************************************************************************************************************
 * @file RBRefObject.h
 **************************************************************************************************************************/


#ifndef __RBREFOBJECT_H__
#define __RBREFOBJECT_H__


/**************************************************************************************************************************
 * Includes
 **************************************************************************************************************************/
#include <RBMain/RBCommon.h>
#include <RBMain/RBMemObject.h>
#include <RBMain/RBSmartPointer.h>

/**************************************************************************************************************************
 * Forward declarations
 **************************************************************************************************************************/

/**************************************************************************************************************************
 * Classes
 **************************************************************************************************************************/

class RBRefObject : public RBMemObject
{
    RBDeclareRTTI(RBRefObject, RBMemObject);

public:
                         RBRefObject        ();
    virtual             ~RBRefObject        ();

    uint32               IncRefCount        ();
    uint32               DecRefCount        ();

    uint32               GetRefCount        () const { return m_uiRefCount; }
    static uint32        GetNbObjects       ()       { return ms_uiNbObjects ; }

protected:
    virtual void         DeleteThis();

private:
    uint32               m_uiRefCount;
    static uint32        ms_uiNbObjects;
};

RBDeclareSmartPointer(RBRefObject);

/**************************************************************************************************************************/

#include "RBRefObject.inl"

#endif // __RBREFOBJECT_H__
